// pages/library/popularCategories/popularCategories.js
Page({
    data: {
        header: '',
        tage1_content: [],
        tage2_content: [],
        tage3_content: [],
        tage4_content: [],
        tage5_content: [],
        tage6_content: [],
        tage7_content: [],
        tage8_content: [],
        tage9_content: [],
        tage10_content: [],
        tage11_content: [],
        tage12_content: [],
      
          
          
    },
   
    onLoad: function (options) {
        const name = options.name;
        var that = this;
        if (name === '写雨') {
            that.getTageContent('tage1');
            that.setData({
            header: '写雨',
            content: that.data.tage1_content
          })
        } else if (name === '写雪') {
            that.setData({
            header: '写雪',
            content: '友情内容'
          })
        } else if (name === '写风') {
            that.setData({
             header:'写风',
             content:''
         })
        }else if (name === '写花') {
            that.setData({
                header:'写花',
                content:''
            })
           }else if (name === '写山') {
            that.setData({
                header:'写山',
                content:''
            })
           }else if (name === '写水') {
            that.setData({
                header:'写水',
                content:''
            })
           }else if (name === '春天') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '夏天') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '秋天') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '冬天') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '母亲') {
            that.setData({
                header:'',
                content:''
            })
           }else if (name === '老师') {
            that.setData({
                header:'',
                content:''
            })
           }
      },
      getTageContent: function (tage) {
        var that = this;
        wx.request({
          url: 'http://127.0.0.1:5000/app/' + tage,
    
          success: function (res) {
            console.log('Response:', res);
            that.setData({
              [tage + '_content']: res.data ,// 成功获取内容后将其保存在对应标签的 content 属性中
            //   currentTagContent: res.data
            });
          },
          fail: function (err) {
            console.error('Failed to fetch data:', err); // 检查请求失败的情况
        }
        });
      },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})